#ifndef __XMESH_COLLECTION_H
#define __XMESH_COLLECTION_H

#if defined(HAVE_STD_UNORDERED_COLLECTIONS)

#include <unordered_map>
#include <unordered_set>

#elif defined(HAVE_TR1_UNORDERED_COLLECTIONS)

#include <tr1/unordered_map>
#include <tr1/unordered_set>

namespace std {

	template <typename Key, typename T, typename Hash,
		typename Pred = std::equal_to<Key> >
		class unordered_map : public std::tr1::unordered_map<Key, T, Hash, Pred> {
	};

	template <typename Value, typename Hash,
		typename Pred = std::equal_to<Value> >
		class unordered_set : public std::tr1::unordered_set<Value, Hash, Pred> {
	};
}


#elif defined(HAVE_BOOST_UNORDERED_COLLECTIONS)

#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include <functional>

namespace std {

  template <typename Key, typename T, typename Hash,
            typename Pred = std::equal_to<Key> >
  class unordered_map : public boost::unordered_map<Key, T, Hash, Pred> {

  public:
    typedef T data_type;

  };

  template <typename Value, typename Hash,
            typename Pred = std::equal_to<Value> >
  class unordered_set : public boost::unordered_set<Value, Hash, Pred> {
  };

}


#elif defined(HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS)

#include <ext/hash_map>
#include <ext/hash_set>

namespace std {

  template<typename K, typename V, typename H = __gnu_cxx::hash<K> >
  class unordered_map : public __gnu_cxx::hash_map<K, V, H> {
    typedef __gnu_cxx::hash_map<K, V, H> super;
  public:
    typedef typename super::data_type mapped_type;
    unordered_map() : super() {}
  };

  template<typename K, typename H = __gnu_cxx::hash<K> >
  class unordered_set : public __gnu_cxx::hash_set<K, H> {
    typedef __gnu_cxx::hash_set<K, H> super;
  public:
    unordered_set() : super() {}
  };
}


#elif defined(_MSC_VER) && _MSC_VER >= 1300

#include <hash_map>
#include <hash_set>

namespace std {

  namespace {

    template<class Value, class Hash> class hash_traits {
      Hash hash_value;
      std::less<Value> comp;
    public:
      enum {
        bucket_size = 4,
        min_buckets = 8
      };
      // hash _Keyval to size_t value
      size_t operator()(const Value& v) const {
        return ((size_t)hash_value(v));
      }
      // test if _Keyval1 ordered before _Keyval2
      bool operator()(const Value& v1, const Value& v2) const {
        return (comp(v1, v2));
      }
    };

  }

  template <typename Key, typename T, typename Hash = stdext::hash_compare<Key, less<Key> >, typename Pred = std::equal_to<Key> >
  class unordered_map 
    : public stdext::hash_map<Key, T, hash_traits<Key, Hash> > {
    typedef stdext::hash_map<Key, T, hash_traits<Key, Hash> > super;
  public:
    unordered_map() : super() {}
  };

  template <typename Value, typename Hash = stdext::hash_compare<Key, less<Key> >, typename Pred = std::equal_to<Value> >
  class unordered_set
    : public stdext::hash_set<Value, hash_traits<Value, Hash> > {
    typedef stdext::hash_set<Value, hash_traits<Value, Hash> > super;
  public:
    unordered_set() : super() {}
  };

}


#else

#include <set>
#include <map>

namespace std {

  template<typename K, typename V, typename H = int>
  class unordered_map : public std::map<K, V> {
    typedef std::map<K, V> super;
  public:
    typedef typename super::data_type mapped_type;
    unordered_map() : super() {}
  };

  template<typename K, typename H = int>
  class unordered_set : public std::set<K> {
    typedef std::set<K> super;
  public:
    unordered_set() : super() {}
  };

}


#endif


namespace math 
{
	
}
#endif
